package com.huanke.iot.log.controller;

import com.huanke.iot.base.api.ApiResponse;
import com.huanke.iot.base.po.Alarms.Alarms;
import com.huanke.iot.log.service.AlarmService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author AAJ
 * @version 1.0
 * @date 2020/11/27
 */
@RestController
@Slf4j
@RequestMapping("/alarms")
public class LogController {

    @Autowired
    AlarmService alarmService;

    @PostMapping("/add")
    public void getAllCache(@RequestBody Alarms alarms) {
        alarmService.addOrUpdate(alarms);
    }

    @GetMapping("/findAll")
    public ApiResponse removeAll() {
        List<Alarms> alarmsList = alarmService.findAll();
        return new ApiResponse(alarmsList);
    }

}
